package com.qfedu.fy.controller;

import com.qfedu.fy.dto.UserLoginDto;
import com.qfedu.fy.entity.Department;
import com.qfedu.fy.entity.User;
import com.qfedu.fy.service.intf.DepartmentService;
import com.qfedu.fy.service.intf.UserService;
import com.qfedu.fy.vo.PageBeanVo;
import com.qfedu.fy.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * ......................我佛慈悲......................
 * _oo0oo_
 * o8888888o
 * 88" . "88
 * (| -_- |)
 * 0\  =  /0
 * ___/`---'\___
 * .' \\|     |// '.
 * / \\|||  :  |||// \
 * / _||||| -卍-|||||- \
 * |   | \\\  -  /// |   |
 * | \_|  ''\---/''  |_/ |
 * \  .-\__  '-'  ___/-. /
 * ___'. .'  /--.--\  `. .'___
 * ."" '<  `.___\_<|>_/___.' >' "".
 * | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 * \  \ `_.   \_ __\ /__ _/   .-` /  /
 * =====`-.____`.___ \_____/___.-`___.-'=====
 * `=---='
 * ..............佛祖保佑无BUG..................
 *
 * @author mxj
 * @date 2022/6/16 20:30
 */
@RestController
@RequestMapping("/api/user/")
public class UserController {
    @Autowired
    private UserService service;


    @PostMapping("save.do")
    public R save(User user){
        return service.add(user);
    }

    @GetMapping("page.do")
    public PageBeanVo page(int page,int limit){
        return service.selectAll(page,limit);
    }

    @PostMapping("update.do")
    public R update(User user){
        return service.update(user);
    }

    @PostMapping("del.do")
    public R del(int id){
        return service.del(id);
    }

    @PostMapping("login.do")
    public R login(UserLoginDto dto, HttpSession session){
        return service.login(dto,session);
    }
}
